package com.swanclouds.redfish.chassis;

import com.google.common.base.Preconditions;
import com.swanclouds.api.chassis.PowerService;
import com.swanclouds.core.transport.ClientConstants;
import com.swanclouds.model.chassis.Power;
import com.swanclouds.model.common.ActionResponse;
import com.swanclouds.redfish.common.redfish.PowerControl;
import com.swanclouds.redfish.chassis.domain.PowerModel;
import com.swanclouds.redfish.internal.BaseChassisService;

/**
 * Title: PowerServiceImpl
 * Description: TODO
 * Author: HuangFuYuHui
 * Date: 2022-07-16 11:31.
 */
public class PowerServiceImpl extends BaseChassisService implements PowerService {

    /**
     * 查询指定服务器机箱的电压、功率和电源信息。
     * @return  com.swanclouds.model.chassis.Power
     **/
    @Override
    public Power get() {
        return get(PowerModel.class,uri(ClientConstants.PATH_CHASSIS_POWER,getChassisId())).execute();
    }

   /**
    * 修改指定服务器机箱的电源功耗信息
    * @param  powerControl 修改指定服务器机箱电源的参数
    * @return  com.swanclouds.model.common.ActionResponse
    **/
    @Override
    public ActionResponse updatePowerAttribute(PowerControl powerControl) {
        Preconditions.checkNotNull(powerControl, "powerControl is null");
        Preconditions.checkNotNull(powerControl.getPowerLimits(), "powerLimits is null");
        get();
        return  patch(ActionResponse.class,uri(ClientConstants.PATH_CHASSIS_POWER,getChassisId()))
                .entity(powerControl)
                .execute();
    }

}
